﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;

namespace Cloud.Core.AuthUser
{
    public class Power
    {
        public bool Add { get; set; }
        
        public bool Delete { get; set; }

        public bool Search { get; set; }

        public bool Edit { get; set; }

        public bool OutPut { get; set; }

        public bool Print { get; set; }


        public Power()
        {
            SetValue(false);
        }

        public void SetValue(bool Value)
        {
            Add = Value;
            Edit = Value;
            Delete = Value;
            Search = Value;
            OutPut = Value;
            Print = Value;
        }

        public bool AllBool()
        {
            return Add | Edit | Delete | Search | OutPut | Print;
        }

        public void InPutPower(string Power)
        {
            if (Power == null)
            {
                SetValue(false);
                return;
            }
            Add = Power.Contains("A");
            Edit = Power.Contains("E");
            Delete = Power.Contains("D");
            Search = Power.Contains("S");
            OutPut = Power.Contains("O");
            Print = Power.Contains("P");
        }

        public string OutPutString()
        {
            string res = "";
            res += Add ? "A" : "";
            res += Edit ? "E" : "";
            res += Delete ? "D" : "";
            res += Search ? "S" : "";
            res += OutPut ? "O" : "";
            res += Print ? "P" : "";
            return res;
        }
    }
}
